<template>
  <div class="factory-content-item">
    <!-- 枚举类型 -->
    <template v-if="config.valueType == '1'">
      <el-select
        v-model="config.operationValue"
        multiple
        filterable
        reserve-keyword
        placeholder="请选择值"
        :disabled="disabled"
      >
        <el-option
          v-for="enumItem in config.enums"
          :key="enumItem.cdVal"
          :label="enumItem.cdDesc"
          :value="enumItem.cdVal"
        ></el-option>
      </el-select>
    </template>
    <!-- 字符类型 -->
    <template v-if="config.valueType == '2'">
      <el-input v-model="config.operationValue" placeholder="请输入值" :disabled="disabled"></el-input>
    </template>
    <!-- 标识类型 -->
    <template v-else-if="config.valueType == '3'">
      <el-select v-model="config.operationValue" placeholder="请选择值" :disabled="disabled">
        <el-option label="是" value="1"></el-option>
        <el-option label="否" value="0"></el-option>
      </el-select>
    </template>
    <!-- 日期 -->
    <template v-if="config.valueType == '4'">
      <template v-if="config.operationType === 'a<=x<b'">
        <el-date-picker
          v-model="config.operationValue"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          :key="config.tagId + 'range'"
          :disabled="disabled"
        ></el-date-picker>
      </template>
      <template v-else-if="config.operationType === 8">
        在过去
        <el-input-number
          v-model="config.operationValue[0]"
          :min="1"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        天
        <el-select v-model="config.operationValue[1]" placeholder="请选择值" class="normal" :disabled="disabled">
          <el-option label="之内" value="1"></el-option>
          <el-option label="之前" value="0"></el-option>
        </el-select>
      </template>
      <template v-else-if="config.operationType === 9">
        在过去
        <el-input-number
          v-model="config.operationValue[0]"
          :min="1"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        天至过去
        <el-input-number
          v-model="config.operationValue[1]"
          :min="1"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        天之间
      </template>
      <el-date-picker
        v-model="config.operationValue"
        type="date"
        placeholder="选择日期"
        value-format="yyyy-MM-dd"
        :key="config.tagId + 'single'"
        :disabled="disabled"
        v-else
      ></el-date-picker>
    </template>
    <!-- 日期时间 -->
    <template v-if="config.valueType == '5'">
      <template v-if="config.operationType === 'a<=x<b'">
        <el-date-picker
          v-model="config.operationValue"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          :key="config.tagId + 'range'"
          :disabled="disabled"
        ></el-date-picker>
      </template>
      <template v-else-if="config.operationType === 8">
        在过去
        <el-input-number
          v-model="config.operationValue[0]"
          :min="1"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        天
        <el-select v-model="config.operationValue[1]" placeholder="请选择值" class="normal" :disabled="disabled">
          <el-option label="之内" value="1"></el-option>
          <el-option label="之前" value="0"></el-option>
        </el-select>
      </template>
      <template v-else-if="config.operationType === 9">
        在过去
        <el-input-number
          v-model="config.operationValue[0]"
          :min="1"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        天至过去
        <el-input-number
          v-model="config.operationValue[1]"
          :min="1"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        天之间
      </template>
      <el-date-picker
        v-model="config.operationValue"
        type="datetime"
        placeholder="选择时间"
        value-format="yyyy-MM-dd HH:mm:ss"
        :key="config.tagId + 'single'"
        :disabled="disabled"
        v-else
      ></el-date-picker>
    </template>
    <!-- 整数数值 -->
    <template v-if="config.valueType == '6'">
      <template v-if="config.operationType === 'a<=x<b'">
        <el-input-number
          v-model="config.operationValue[0]"
          :min="0"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        与
        <el-input-number
          v-model="config.operationValue[1]"
          :min="0"
          :step="1"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        之间
      </template>
      <el-input-number
        v-model="config.operationValue"
        :min="0"
        :step="1"
        :step-strictly="true"
        :disabled="disabled"
        v-else
      ></el-input-number>
    </template>
    <!-- 小数数值 -->
    <template v-if="config.valueType == '7'">
      <template v-if="config.operationType === 'a<=x<b'">
        <el-input-number
          v-model="config.operationValue[0]"
          :min="0.0"
          :step="0.01"
          :precision="2"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        与
        <el-input-number
          v-model="config.operationValue[1]"
          :min="0.0"
          :step="0.01"
          :precision="2"
          :step-strictly="true"
          class="normal"
          :disabled="disabled"
        ></el-input-number>
        之间
      </template>
      <el-input-number
        v-model="config.operationValue"
        :min="0.0"
        :step="0.01"
        :precision="2"
        :step-strictly="true"
        :disabled="disabled"
        v-else
      ></el-input-number>
    </template>
    <template v-if="!config.valueType">
      <el-input v-model="config.operationValue" placeholder="请输入值" :disabled="disabled"></el-input>
    </template>
  </div>
</template>

<script>
export default {
  props: {
    config: {
      type: Object,
      required: true,
      default: () => {}
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {}
  },
  methods: {}
}
</script>

<style lang="scss">
.tag-factory .factory-content .list-wrap .el-form-item {
  .factory-content-item {
    background-color: #f6f7f8;
    .el-input__inner,
    .el-range-editor .el-range-input,
    .el-select__input {
      background-color: #fff;
      border: 1px solid #c0d2f6;
    }
    .el-select__tags .el-select__input,
    .el-date-editor .el-range-input {
      border: 0;
    }
  }
}
</style>
